<?php
    use User\Model\MeetingModel;
?>
<!-- page heading start-->
<div class="page-heading">
    <h3>
        会议列表
    </h3>

</div>
<!-- page heading end-->
<div class="row">
    <div class="col-sm-12">
        <section class="panel">
            <header class="panel-heading">
                <a class="btn btn-default" href="/User/Meeting/meetingAdd">增加</a>
            </header>
            <div class="panel-body">
                <table class="table table-hover general-table table-bordered">
                    <thead>
                    <tr>
                        <th width="12%">会议名称</th>
                        <th width="12%">链接首页地址</th>
                        <th width="8%">状态</th>
                        <th width="10%">创建时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach($list as $val){?>
                    <tr>
                        <td>
                            <span>
                                <?php echo $val['name'];?>
                            </span>
                        </td>
                        <td>
                            <span style="word-wrap:break-word">
                                <?php
                             echo "会议首页地址:" . "<br>";
                                 if($val['has_head']){
                                    echo "http://" . $_SERVER['SERVER_NAME'] . "/Wap/Meeting/entry?meetId=" . $val['meet_id'];
                                 }else{
                                    $cond['status'] = MeetingModel::STATUS_ACTIVE;
                                    $cond['meet_id'] = $val['meet_id'];
                                    $count = M("meeting_menu")->where($cond)->count();
                                    if($count == 0 && $val['need_register']){
                                        echo "http://" . $_SERVER['SERVER_NAME'] . "/Wap/Meeting/index?meetId=" . $val['meet_id'] . "&is_register=1";
                                    }else{
                                        echo "http://" . $_SERVER['SERVER_NAME'] . "/Wap/Meeting/index?meetId=" . $val['meet_id'];
                                    }

                                 }
                                 echo "<br>" . "会议管理登录地址:" . "<br>";
                                 echo "http://" . $_SERVER['SERVER_NAME'] . "/Wap/Applications/meeting_activity";

                                 if(!empty($val['live'])){
                                    $live_arr = explode("|", $val['live']);
                                    if(in_array(MeetingModel::LIVE_SIGNIN, $live_arr)){
                                        echo "<br>" . "签到观看地址:" . "<br>";
                                        echo "http://" . $_SERVER['SERVER_NAME'] . "/Wap/Meeting/sign?meetId=" . $val['meet_id'];
                                    }
                                    if(in_array(MeetingModel::LIVE_LUCKY, $live_arr)){
                                        echo "<br>" . "现场抽奖地址:" . "<br>";
                                        echo "http://" . $_SERVER['SERVER_NAME'] . "/Wap/Meeting/lucky?meetId=" . $val['meet_id'];
                                    }
                                }
                                ?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo MeetingModel::getStatus($val['status']);?>
                            </span>
                        </td>
                        <td>
                            <span>
                                <?php echo $val['create_date'];?>
                            </span>
                        </td>
                        <td>
                            <div>
                                <a class="btn btn-success"
                                   href="<?php echo '/User/Meeting/meetingUpdate?type=update&meetId=' . $val['meet_id'];?>">编辑</a>
                                <a class="btn btn-info" href="#"
                                   onclick="<?php echo 'return active_data(' . $val['meet_id'] .')';?>">发布</a>
                                <a class="btn btn-warning" href="#"
                                   onclick="<?php echo 'return pending_data(' . $val['meet_id'] .')';?>">停用</a>
                                <a class="btn btn-default" href="#"
                                   onclick="<?php echo 'return delete_data(' . $val['meet_id'] .')';?>">删除</a>
                                <a class="btn btn-danger" href="<?php echo '/User/Meeting/statistics?meetId=' . $val['meet_id'];?>" >数据统计</a>
                            </div>
                            <div style="margin-top: 20px;">
                                <a class="btn btn-success" href="<?php echo '/User/Meeting/menu?meetId=' . $val['meet_id'];?>" >自定义菜单</a>
                                <a class="btn btn-info" href="<?php echo '/User/Meeting/share?id=' . $val['meet_id'];?>" >分享设置</a>
                                <a class="btn btn-warning" href="<?php echo '/User/Meeting/live?meetId=' . $val['meet_id'];?>" >现场互动</a>
                            </div>
                            <?php if($val['need_register']){?>
                            <div style="margin-top: 20px;">
                                <a class="btn btn-success" href="<?php echo '/User/Meeting/registerField?meetId=' . $val['meet_id'];?>" >报名模块</a>
                                <a class="btn btn-info" href="<?php echo '/User/Meeting/register?meetId=' . $val['meet_id'];?>" >报名列表</a>
                            </div>
                            <?php }?>
                        </td>
                    </tr>
                    <?php }?>

                    </tbody>
                </table>
                <div class="pages">
                    {$page}
                </div>
            </div>
        </section>
    </div>
</div>
<script>
    function delete_data(id){
        $.ajax({
            data:{meetId:id},
            dataType:'json',
            url:'/User/Meeting/meetingDelete',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
    function active_data(id){
        $.ajax({
            data:{meetId:id},
            dataType:'json',
            url:'/User/Meeting/meetingActive',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
    function pending_data(id){
        $.ajax({
            data:{meetId:id},
            dataType:'json',
            url:'/User/Meeting/meetingPend',
            type:'get',
            success:function(res){
                window.location.reload();
            }
        });
        return false;
    }
</script>